package ink.lovejinhu.swardToOffer;

import java.util.Stack;

/**
 * @author jinhu
 * created 2021-08-08 13:59
 */
public class Offer_009 {
    Stack<Integer> v0 = new Stack<Integer>();
    Stack<Integer> v1 = new Stack<Integer>();

    public Offer_009() {

    }

    /**
     * 插入元素
     *
     * @param value
     */
    public void appendTail(int value) {
        v0.push(value);
    }

    /**
     * 删除元素
     *
     * @return
     */
    public int deleteHead() {
        if (v1.isEmpty()) {
            if (v0.isEmpty()) {  //空栈
                return -1;
            } else {
                while (!v0.isEmpty()) {
                    v1.push(v0.pop());
                }
            }
        }
        return v1.pop();
    }
}
